import { User } from '@/types/user'
import { request } from '@/utils/request'

export const getUserInfo = () => {
  return request<User>({
    url: 'admin/detail'
  })
}

export const getUserList = (data: {
  page: number
  pageSize: number
  nickname: string
}) => {
  return request<{ total: number; items: User[] }>({
    url: 'admin/list',
    data
  })
}

// 新增用户
export const addUser = (data: {
  adminname: string
  nickname: string
  status: number
}) => {
  return request({
    url: 'admin/add',
    method: 'POST',
    data
  })
}

// 修改用户
export const editUser = (data: Partial<User>) => {
  return request({
    url: 'admin/update',
    method: 'POST',
    data
  })
}

// 删除用户
export const delUser = (data: { adminid: string }) => {
  return request({
    url: 'admin/delete',
    method: 'POST',
    data
  })
}
